import AttentionApi from '../../../apis/myAttention';
import { message } from 'antd';
import {WeaAlertPage} from 'ecCom'
import Attention from '../../MyBlog/RightContainer/Attention/Attention';
import {inject, observer} from 'mobx-react';
import {observable,action,toJS} from 'mobx';

import { WeaLocaleProvider } from "ecCom";
const getLabel = WeaLocaleProvider.getLabel;

@inject('blogMyAttention')
@observer
class HisAttentions extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			attentionList: []
		};
	}
	componentDidMount() {
		AttentionApi.getMyBlogAttention({blogId: this.props.userId, groupid: 'all'}).then((result) => {
			this.setState({
				attentionList: result.attentionList || []
			});
		}).catch(error => message.error(error));
	}
	render() {
		let list = this.state.attentionList;
		return (
			<div className="hisAttention">
				{
					list && list.length == 0 && <WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@zcl8aw`} icon="icon-blog-blank">
					<div>{getLabel(83553,"暂无数据")}</div>
				</WeaAlertPage>
				}
				{list.map((item) => {
					item.attentionStatus = undefined;
					item.attentionMeStatus = undefined;
					return (
							<Attention ecId={`${this && this.props && this.props.ecId || ''}_Attention@jrwih4@${item.userId}`}
							key={item.userId}
							type="attention"
							data={item}
						/>
					);
				})}
			</div>
		);
	}
}

export default HisAttentions;